<template>
  <v-chart :options="line"
           :auto-resize="true" />
</template>

<style></style>

<script>
import ECharts from 'vue-echarts'
import 'echarts/lib/chart/line'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/title'
import moment from 'moment'

export default {
  props: {
    chartData: Array,
  },
  components: {
    'v-chart': ECharts,
  },
  data () {
    return {
      line: {
        xAxis: {
          type: 'time',
          axisLabel: {
            formatter: function (value) {
              return moment(value).format('YYYY-MM-DD hh:mm:ss')
            },
          },
          splitLine: {
            show: false,
          },
          name: '时间',
          nameLocation: 'middle',
          nameTextStyle: {
            fontSize: 16,
            padding: 10,
          },
        },
        yAxis: {
          type: 'value',
          min: 30,
          max: 45,
          splitLine: {
            show: false,
          },
          name: '体温',
          nameLocation: 'middle',
          nameTextStyle: {
            fontSize: 16,
            padding: 10,
          },
        },
        series: [
          {
            data: this.chartData,
            type: 'line'
          },
        ],
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        }
      },
    }
  },
}
</script>

